package cn.edu.xyc.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.xyc.dao.BaseDao;
import cn.edu.xyc.domain.EntityPojo;
import cn.edu.xyc.pojo.Resultinfo;
import cn.edu.xyc.service.QueryService;

@Service(QueryService.QUERYS_ERVICE_NAME)
public class QueryServiceImpl implements QueryService {

	@Autowired
	private BaseDao<EntityPojo> edao;

	@Override
	public Resultinfo queryinfo(String idcard, String username) {
		
		String hql = "from EntityPojo e where e.name=:name and e.idcard=:idcard";

		Map<String, Object> m = new HashMap<String, Object>();
		m.put("idcard", idcard);
		m.put("name", username);

		List<EntityPojo> find = edao.findbyhql(hql, m);
		
		Resultinfo resultinfo = new Resultinfo();

		if (null != find && !find.isEmpty()) {
			BeanUtils.copyProperties(find.get(0), resultinfo);
		} else {
			System.out.println("数据不存在");
			return null;
		}
		return resultinfo;
	}

}
